package com.mp.chart.charts;

import android.content.Context;
import android.util.AttributeSet;

import com.mp.chart.data.LineData;
import com.mp.chart.formatter.FillFormatter;
import com.mp.chart.interfaces.TimeLineDataProvider;
import com.mp.chart.renderer.TimeLineChartRenderer;


public class TimeLineChart extends BarLineChartBase<LineData> implements TimeLineDataProvider {
    private FillFormatter mFillFormatter;

    public TimeLineChart(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public TimeLineChart(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public TimeLineChart(Context context) {
        super(context);
    }


    @Override
    protected void init() {
        super.init();

        mRenderer = new TimeLineChartRenderer(this, mAnimator, mViewPortHandler);

        mFillFormatter = new DefaultFillFormatter();
    }

    @Override
    protected void calcMinMax() {
        super.calcMinMax();

        // // if there is only one showapi_res_body in the com.mp.chart
        // if (mOriginalData.getYValCount() == 1
        // || mOriginalData.getYValCount() <= mOriginalData.getDataSetCount()) {
        // mDeltaX = 1;
        // }

        if (mDeltaX == 0 && mData.getYValCount() > 0)
            mDeltaX = 1;
    }

    @Override
    public void setFillFormatter(FillFormatter formatter) {

        if (formatter == null)
            formatter = new DefaultFillFormatter();
        else
            mFillFormatter = formatter;
    }

    @Override
    public FillFormatter getFillFormatter() {
        return mFillFormatter;
    }

    @Override
    public LineData getLineData() {
        return mData;
    }
}
